using System.Text;
using Microsoft.Ajax.Utilities;
using Shinkansen.Support;

namespace Shinkansen.Crunchers
{
    public class MicrosoftJsCruncher : IJsCruncher
    {
        /// <summary>
        /// Gets crunched content.
        /// </summary>
        /// <param name="content">The content.</param>
        /// <returns></returns>
        public byte[] Process (byte[] content)
        {
            string      plainContent = Encoding.UTF8.GetString (content);
            Minifier    minifier = new Minifier ();
            string      crunchedContent = minifier.MinifyJavaScript (plainContent);

            return Encoding.UTF8.GetBytes (crunchedContent);
        }
    }
}
